'''
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License") you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http:#www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
'''
from base.rdf.Literal import Literal
from base.rdf.Property import Property
from base.rdf.Resource import Resource
from base.rdf.impl.NodeIteratorImpl import NodeIteratorImpl
from base.rdf.impl.ResIteratorImpl import ResIteratorImpl
# from base.rdf.impl.StmtIteratorImpl import StmtIteratorImpl
from base.util.iterator.impl.WrappedIterator import WrappedIterator

#import java.util.*;

#import org.apache.jena.graph.*;
#import org.apache.jena.rdf.model.*;
#import org.apache.jena.util.iterator.*;


'''
 * Builds Jena Iterators and other things (RDFNode and Statement)
 * needed in a Model.
'''
class IteratorFactory:

    #private IteratorFactory():
    

    '''
     *
    '''
    # param Iterator<Triple> i, final ModelCom m
    # result StmtIterator
    @staticmethod
    def asStmtIterator(i, m):
        pass
        # TODO
        # return StmtIteratorImpl(WrappedIterator.create(i).mapWith(lambda t: m.asStatement(t)))
    

    '''
     *
    '''
    # param Iterator<Node> i, final ModelCom m
    # result ResIterator
    @staticmethod
    def asResIterator(i, m):
        return ResIteratorImpl(WrappedIterator.create(i).mapWith(lambda o: m.asRDFNode(o)))
    

    '''
     *
    '''
    # param Iterator<Node> i, final ModelCom m
    # result NodeIterator
    @staticmethod
    def asRDFNodeIterator(i, m):
        return NodeIteratorImpl(WrappedIterator.create(i).mapWith(lambda o: m.asRDFNode(o)))

    @staticmethod
    # param Node n, ModelCom m
    # result static Resource
    def asResource(n, m):
        return IteratorFactory.asResourceWithClass(n, Resource, m)
    

    # param Ndoe n, ModelCom m
    # static Property
    def asProperty(n, m):
        #return (Property) asResource(n, Property.class, m)
        return IteratorFactory.asResourceWithClass(n, Property, m)

    

    # param Node n, ModelCom m
    # result static Literal
    def asLiteral(n, m):
        return m.getNodeAs(n, Literal)
    

    # param Node n, Class<X> cl, ModelCom m
    # static <X extends RDFNode> Resource
    def asResourceWithClass(n, cl, m):
        return m.getNodeAs(n, cl)
    

